﻿$(function () {
    var gds = $(".gdlistview .gd-area .gd-list .gd-item").toArray();

    //排序按钮点击事件
    $(".type-head .rank-types .blkfont > li").on("click", function (e) {
        $(".type-head .rank-types .blkfont > li").removeClass("sel");
        $(this).addClass("sel");
        var id = this.id;
        switch (id) {
            case "rank-hot":
            case "rank-rem-asc": {
                gds = Enumerable.from(gds).orderBy(o => parseInt(o.getAttribute("data-rem"))).toArray();
                break;
            }
            case "rank-new": {
                gds = Enumerable.from(gds).orderBy(o => parseInt(o.getAttribute("data-time"))).toArray();
                break;
            }
            case "rank-rem-desc": {
                gds = Enumerable.from(gds).orderByDescending(o => parseInt(o.getAttribute("data-rem"))).toArray();
                break;
            }
            case "rank-all-asc": {
                gds = Enumerable.from(gds).orderBy(o => parseInt(o.getAttribute("data-all"))).toArray();
                break;
            }
            case "rank-all-desc": {
                gds = Enumerable.from(gds).orderByDescending(o => parseInt(o.getAttribute("data-rem"))).toArray();
                break;
            }
        }

        $(".gdlistview .gd-area .gd-list .gd-item").remove();
        $(".gdlistview .gd-area .gd-list").append(gds);
        Tools.bindGdItemBtnEvents();
    });
})